  public function getCartProcessedItemsAttributeName()
  {
    return $this->getModuleName().'_batch_edition_processed_items';
  }

  public function getCartProcessedItems($default = array())
  {
    return sfContext::getInstance()->getUser()->getAttribute($this->getCartProcessedItemsAttributeName(), $default);
  }

  public function setCartProcessedItems($items)
  {
    sfContext::getInstance()->getUser()->setAttribute($this->getCartProcessedItemsAttributeName(), $items);
  }

  public function getCartProcessedItemsAsObjects()
  {
    if (count($items = $this->getCartProcessedItems()) > 0)
    {
      $criteria = new Criteria();
      $criteria->add(constant(constant("<?php echo $this->getModelClass() ?>::PEER")."::ID"), $items, Criteria::IN);
      return call_user_func(array(constant("<?php echo $this->getModelClass() ?>::PEER"), $this->getPeerMethod()), $criteria);
    }
    return array();
  }

  public function getCartAttributeName($namespace = null)
  {
    $namespace = is_null($namespace)? $this->getModuleName() : $namespace;
    return $namespace.'_batch_edition_items';
  }

  public function getCartItems($default = array(), $namespace = null)
  {
    return sfContext::getInstance()->getUser()->getAttribute($this->getCartAttributeName($namespace), $default);
  }

  public function setCartItems($items)
  {
    sfContext::getInstance()->getUser()->setAttribute($this->getCartAttributeName(), $items);
  }

  public function getCartItemsAsObjects($condition = null, $namespace = null, &$failed_items = array())
  {
    if (!is_array($failed_items)) $failed_items = array();

    if (count($items = $this->getCartItems(array(), $namespace)) > 0)
    {
      $criteria = new Criteria();
      $criteria->add(constant(constant("<?php echo $this->getModelClass() ?>::PEER")."::ID"), $items, Criteria::IN);
      $items = call_user_func(array(constant("<?php echo $this->getModelClass() ?>::PEER"), $this->getPeerMethod()), $criteria);

      if (!is_null($condition) && '' != trim($condition))
      {
        $filtered = array_filter($items, create_function('$item', 'return $item->'.$condition.'();'));
        $failed_items = array_diff($items, $filtered);
        return $filtered;
      }

      return $items;
    }
    
    return array();
  }
